package com.araaya.eslimsmobile;

import java.util.ArrayList;
import java.util.HashMap;

import com.araaya.eslimsmobile.R;
import com.araaya.eslimsmobile.util.ElandConstant;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class KmlHome extends Activity{
	
	private boolean isWeb;
	public static ArrayList<HashMap<String, String>> pointList;
	public static int ACCURACY_LEVEL=10;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		
		super.onCreate(savedInstanceState);
		setContentView(R.layout.kml_home);
		
		pointList = new ArrayList<HashMap<String, String>>();
		
		isWeb=getIntent().getExtras().getBoolean("web");
		
		final Button btnNewLand = (Button) findViewById(R.id.btnNewLand);
		final Button btnAdjacentLand = (Button) findViewById(R.id.btnAdjacentLand);
		final Button btnShowLand = (Button) findViewById(R.id.btnShowLand);
		final Button btnKmlBack = (Button) findViewById(R.id.btnKmlBack);
		
		if(isWeb){
			btnShowLand.setText(ElandConstant.ATTACH_KML_STR);
		}else{
			btnShowLand.setText(ElandConstant.SHOW_LAND_MAP_STR);
		}
		

		// NewLand Button -- Add a new Land kml
		btnNewLand.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				/*Intent i = new Intent(getBaseContext(), NewLand.class);
				startActivity(i);*/
				Intent i = new Intent(getApplicationContext(),
						LocationMapper.class);
				startActivity(i);
			}
		});
		
		// AdjacentLand Button -- Add a new AdjacentLand kml
        btnAdjacentLand.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {

                Intent i = new Intent(getBaseContext(), LandListForAdjacentLand.class);
                startActivity(i);

            }
        });

		// Show Land Button -- Show all lands
		btnShowLand.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				//MyItemizedOverlay.isToutch=false;
				Intent i = new Intent(getBaseContext(), LandList.class);				
				i.putExtra("web",isWeb);
				if(isWeb){
					i.putExtra("landId", getIntent().getExtras().getLong("landId"));
					i.putExtra("userName", getIntent().getExtras().getString("userName"));
					
				}
				startActivity(i);

			}
		});

		// Back Button
		btnKmlBack.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				finish();
				
			}
		});
	}

}
